/**  
 * @Title: ExamplePlugin.java  
 * @Package com.blog4java.mybatis.configuration.plugin  
 * @Description: TODO(用一句话描述该文件做什么)  
 * @author suyuhao  
 * @date 2025-05-29 12:04:08   
 */
package com.blog4java.mybatis.configuration.plugin;

import java.sql.Connection;
import java.util.Properties;

import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.RowBounds;

/**  
* @ClassName: ExamplePlugin  
* @Description: 此插件将会拦截在 Executor 实例中所有的 “update” 方法调用, 
* 				这里的 Executor 是负责执行底层映射语句的内部对象  
* @author suyuhao  
* @date 2025-05-29 12:04:08
*/
@Intercepts({@Signature(
  type= Executor.class,
  method = "update",
  args = {MappedStatement.class,Object.class})})
/*  
@Intercepts({@Signature(method = "query",type = Executor.class,args = {
		          MappedStatement.class,Object.class,RowBounds.class,
		          ResultSetHandler.class}),
			@Signature(method = "prepare",type= StatementHandler.class,args = {Connection.class})
})
*/
public class ExamplePlugin implements Interceptor{
   private Properties properties = new Properties();
   
   /* (non-Javadoc)
    * @see org.apache.ibatis.plugin.Interceptor#intercept(org.apache.ibatis.plugin.Invocation)
    */
   @Override
   public Object intercept(Invocation invocation) throws Throwable {
	  // implement pre processing if need
	  Object returnObject = invocation.proceed();
	  // implement post processing if need
	  return returnObject;
   }
   
   @Override
   public void setProperties(Properties properties) {
     this.properties = properties;
   }
}
